package odgs.message.client;

import odgs.Connection;
import odgs.GridState;
import odgs.message.Message;
import odgs.message.MessageHandler;
import odgs.message.MessageProcessor;
import odgs.transaction.ContentsAddTransaction;

public class ContentsAddTransactionResponseHandler implements MessageHandler
{
	public void execute(MessageProcessor processor, Message msg, Connection con)
	{
		ContentsAddTransaction tran = (ContentsAddTransaction) msg.get("transaction");
		GridState state = (GridState) msg.get("state");
		if(msg.getResult() < 0)
		{
			processor.getTransactionManager().error(msg.getResult(), tran);
		}
		else
		{
			processor.getDataManager().addContents(tran.getSource());
			processor.getDataManager().setGridState(state);
			processor.getTransactionManager().doneTransaction(tran.getRequestId());
		}
	}
}